{% extends 'layout.html' %}

{% block content %}
    <div class="luffy-container">
        <form action="?type=generate" method="post">
            {% csrf_token %}
            {{ generate_formset.management_form }}
            <div class="panel panel-default">
                <!-- Default panel contents -->
                <div class="panel-heading">
                    <i class="fa fa-th-list" aria-hidden="true"></i>待新建的权限列表
                    <button class="right btn btn-success btn-xs" style="padding: 2px 8px; margin: -3px;"
                            href="{% url 'rbac:multi_permission' %}"
                            style=" margin: -3px;">
                        <i class="fa fa-plus-square" aria-hidden="true"></i> 新建
                    </button>

                </div>
                <!-- Table -->
                <table class="table">
                    <thead>
                    <tr>
                        <th>序号</th>
                        <th>名称</th>
                        <th>Url</th>
                        <th>别名</th>
                        <th>父权限</th>
                        <th>菜单</th>
                    </tr>
                    </thead>
                    <tbody>
                    {% for form in generate_formset %}
                        <tr>
                            <td>{{ forloop.counter }}</td>
                            {% for field in form %}
                                <td>{{ field }} <span style="color: red">{{ field.errors.0 }}</span></td>
                            {% endfor %}
                        </tr>
                    {% endfor %}
                    </tbody>
                </table>
            </div>
        </form>
        <div class="panel panel-default">
            <!-- Default panel contents -->
            <div class="panel-heading">
                <i class="fa fa-th-list" aria-hidden="true"></i>待删除的权限列表
            </div>
            <!-- Table -->
            <table class="table">
                <thead>
                <tr>
                    <th>序号</th>
                    <th>名称</th>
                    <th>Url</th>
                    <th>别名</th>
                    <th>操作</th>
                </tr>
                </thead>
                <tbody>
                {% for row in delete_list %}
                    <tr>
                        <td>{{ forloop.counter }}</td>
                        <td>{{ row.title }}</td>
                        <td>{{ row.url }}</td>
                        <td>{{ row.name }}</td>
                        <td><a href="{% url 'rbac:multi_permission_del' pk=row.id %}"><i class="fa fa-trash-o"
                                                                                         aria-hidden="true"></i></a>
                        </td>
                    </tr>
                {% endfor %}
                </tbody>
            </table>
        </div>
        <form action="?type=update" method="post">
            {% csrf_token %}
            {{ update_formset.management_form }}
            <div class="panel panel-default">
                <!-- Default panel contents -->
                <div class="panel-heading">
                    <i class="fa fa-th-list" aria-hidden="true"></i>待更新的权限列表
                    <button class="right btn btn-success btn-xs" style="padding: 2px 8px; margin: -3px;"
                            style=" margin: -3px;">
                        <i class="fa fa-save" aria-hidden="true"></i> 保存
                    </button>
                </div>
                <!-- Table -->
                <table class="table">
                    <thead>
                    <tr>
                        <th>序号</th>
                        <th>名称</th>
                        <th>Url</th>
                        <th>别名</th>
                        <th>菜单</th>
                        <th>父权限</th>
                    </tr>
                    </thead>
                    <tbody>
                    {% for form in update_formset %}
                        <tr>

                            <td>{{ forloop.counter }}</td>
                            {% for field in form %}
                                {% if forloop.first %}
                                    {{ field }}
                                {% else %}
                                    <td>{{ field }} <span style="color: red">{{ field.errors.0 }}</span></td>
                                {% endif %}
                            {% endfor %}
                        </tr>
                    {% endfor %}
                    </tbody>
                </table>
            </div>
        </form>
    </div>
{% endblock %}